Positive integer n is given. Count and print the message “OK”
as shown in the example.
Input. One positive integer n (n ≤ 100).
Output. Print the text “OK”
numbered n times.
Sample input |
Sample output |
3 |
1 OK 2 OK 3 OK |
loop
Use
a for loop. Print
the line numbers and the text “OK”.
Read the input value of n.
scanf("%d", &n);
Print the numbered text “OK” n
times.
for (i = 1; i <= n; i++)
printf("%d
OK\n", i);
Java realization
import java.util.*;
class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
Read the input value of n.
int n = con.nextInt();
Print the numbered text “OK” n
times.
for(int i = 1; i <= n; i++)
System.out.println(i + "
OK");
con.close();
}
}
Python realization
Read the input value of n.
n = int(input())
Print the numbered text “OK” n
times.
for i in range(1,n+1):
print(i,"OK")